# -*- coding:utf-8 -*-

from common.import_pyside import *
from common.data import DB


class RecordStepWindow(QWidget):
    def __init__(self, parent=None):
        super(RecordStepWindow, self).__init__(parent=parent)
        self.mouse_start_pt = None
        self.window_pos = None
        self.drag = None
        self.setTabletTracking(True)
        self.resize(200, 80)
        self.move(1700, 500)
        self.setStyleSheet("background-color: rgba(173, 155, 120, 0.7);border-radius:5px;")
        self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint)
        self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
        layout = QVBoxLayout()
        layout.addWidget(QLabel("2323"))

        self.setLayout(layout)

    def enterEvent(self, event):
        # self.setWindowFlags(Qt.WindowType.WindowTitleHint)
        print("enter")

    def leaveEvent(self, event):
        # self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint)
        print("leaveEvent")

    def mousePressEvent(self, event: QMouseEvent) -> None:
        if event.button() == Qt.LeftButton:
            self.mouse_start_pt = event.globalPosition().toPoint()
            self.window_pos = self.frameGeometry().topLeft()
            self.drag = True

    def mouseMoveEvent(self, event: QMouseEvent) -> None:
        if self.drag:
            distance = event.globalPosition().toPoint() - self.mouse_start_pt
            self.move(self.window_pos + distance)

    def mouseReleaseEvent(self, event: QMouseEvent) -> None:
        if event.button() == Qt.LeftButton:
            self.drag = False


if __name__ == '__main__':
    app = QApplication()
    win = RecordStepWindow()
    win.show()
    app.exec()
